var tpl = "my name is <%name%>. I am <%age%> years old.";

var data = {
    name: "Krasimir",
    age: 29,
};

function render (tpl, data) {
    var re = /<%([\w$.]+)%>/g;
    while(match = re.exec(tpl)) {
        tpl = tpl.replace(match[0], data[match[1]])
    }
    return tpl;
}

console.log(render(tpl, data))